import { defineStore } from "pinia";
import { ref } from "vue";

export const useKeepAliveStore=defineStore('keepAlive',()=>{
     const keepNameLsit=ref<string[]>([])
    //  添加
     const addKeepAliveName= async(name:string)=>{
      if(!keepNameLsit.value.includes(name))
          keepNameLsit.value.push(name)
     }
    //  移除
     const removeKeepAliveName= async(name:string)=>{
      keepNameLsit.value=keepNameLsit.value.filter((item)=>item !== name)
     }

    //  设置 登录别的角色的时候调用这个清空 不然影响另一个角色
    const setKeepAliveName = async(keepAliveName: string[] = []) =>{
      keepNameLsit.value = keepAliveName;
    }

     return {keepNameLsit , addKeepAliveName ,removeKeepAliveName ,setKeepAliveName}
})
